package com.broadsoft.platform.wfengine.runtime.spi;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.broadsoft.platform.wfengine.NodeType;
import com.broadsoft.platform.wfengine.expression.ExpressionHelper;
import com.broadsoft.platform.wfengine.runtime.WfContext;

public class ExpressionDecisionHandler implements DecisionHandler {

    private final static Logger logger = LoggerFactory.getLogger(ExpressionDecisionHandler.class);

    public String handle(NodeType currentNode, WfContext flowContext) {
        String expressionContent = currentNode.getProcessHandler().getExpression().getContent();
        if (logger.isTraceEnabled()) {
            logger.trace("The local variable[expressionContent] is {}.", expressionContent);
        } 
        String value = ExpressionHelper.executeExpression(expressionContent);
        return value;
    }// end of handle

}
